/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pruefung.ss11;

import java.util.*;
import static com.google.common.base.Preconditions.*;

/**
 *
 * @author abg659
 */
public class Aufgaben2 {
    
    public static List<List<List<String>>>makeStringList(int m) {
        checkNotNull(m);
        checkArgument(m>=0);
        
        
        List<List<List<String>>> returnList = new ArrayList<List<List<String>>>();
        List<String> innerlist2 = new ArrayList<String>();
        List<List<String>> innerlist = new ArrayList<List<String>>();
        
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                innerlist = new ArrayList<List<String>>();
                for (int k = 0; k < m; k++) {
                    innerlist2 = new ArrayList<String>();
                    innerlist2.add("i="+i+" j="+j+" k="+k);
                }
                innerlist.add(innerlist2);
            }
            returnList.add(innerlist);
        }
        
        
        return returnList;
    }
    
    public static List<String> flatten(List<List<List<String>>> list) {
        List<String> returnList = new ArrayList<String>();
        
        for (List<List<String>> innerlist : list) {
            for (List<String> innerlist1 : innerlist) {
                for (String innerlist2 : innerlist1) {
                    returnList.add(innerlist2);
                }
            }
        }        
        return returnList;
    }
    
}
